﻿#include "WRWorkLampController.h"
#include "WRWorkStatusPixmaps.h"

//初始化控制器。
WRWorkLampController::WRWorkLampController(QLabel* label)
{
    m_label = label;
    m_status = WRWorkStatus::Unavail;
    m_label->setToolTip(m_status.toString());
    m_label->setPixmap(WRWorkStatusPixmaps::unavail());
}
//设置最新状态。
void WRWorkLampController::status(WRWorkStatus value)
{
    if (m_status != value)
    {
        m_status = value;
        m_label->setToolTip(value.toString());
        switch((WRWorkStatus::Enum)value)
        {
        case WRWorkStatus::Unavail:
            m_label->setPixmap(WRWorkStatusPixmaps::unavail());
            break;
        case WRWorkStatus::Closed:
            m_label->setPixmap(WRWorkStatusPixmaps::closed());
            break;
        case WRWorkStatus::Opening:
            m_label->setPixmap(WRWorkStatusPixmaps::opening());
            break;
        case WRWorkStatus::Ready:
            m_label->setPixmap(WRWorkStatusPixmaps::ready());
            break;
        case WRWorkStatus::Stopped:
            m_label->setPixmap(WRWorkStatusPixmaps::stopped());
            break;
        case WRWorkStatus::Starting:
            m_label->setPixmap(WRWorkStatusPixmaps::starting());
            break;
        case WRWorkStatus::Running:
            m_label->setPixmap(WRWorkStatusPixmaps::running());
            break;
        case WRWorkStatus::Stopping:
            m_label->setPixmap(WRWorkStatusPixmaps::stopping());
            break;
        case WRWorkStatus::Blocked:
            m_label->setPixmap(WRWorkStatusPixmaps::blocked());
            break;
        case WRWorkStatus::Closing:
            m_label->setPixmap(WRWorkStatusPixmaps::closing());
            break;
        case WRWorkStatus::Disposing:
            m_label->setPixmap(WRWorkStatusPixmaps::disposing());
            break;
        case WRWorkStatus::Disposed:
            m_label->setPixmap(WRWorkStatusPixmaps::disposed());
            break;
        default:
            m_label->setPixmap(WRWorkStatusPixmaps::unknown());
            break;
        }
    }
}
